fix: parseStartAndEndTimes with times going over 12:00#330
fix: parseStartAndEndTimes with times going over 12:00#330matt-franklin225 wants to merge 5 commits intomainfrom
Conversation
|
Could we rename the pr to something along the lines of "fix: parseStartAndEndTimes with times going over 12:00". Any end time over 12:00 is now inferred to go over noon instead of midnight, not just the times that end with 12:xx. For example, "10:00-1:00" now goes from 600 to 780 (10:00 am to 1:00 pm) instead of -120 to 60 |
Wait i'm confused. Are we assuming that a midnight course could exist. If so it would logically make sense that '11:00-1:00' would also go through midnight. |
I don't want to rule that out, because that would mean re-scraping Websoc with this fix and seeing whether it's subtly off. The format (particularly, the fact that |
In that case, is the passing midnight situation something we should account for, and if so, how do we handle minutes after midnight? We could either return them as minutes since the most recent midnight or minutes since the starting midnight. |
My best guess is that if there every is a case like that, the date would reference the earlier day, so Mar 9, 11:00-1:00 would probably mean at 11:00 on Mar 9 and ending 1:00 on Mar 10. It would probably be more right to say that the ending time is after 24*60, then to have a negative start time |
Lmk what you think of the new version |
Previous issue should be fixed now |
packages/stdlib/src/time-utils.ts
Outdated
| if (endTimeMinute.includes("p") && startTime <= endTime) startTime += 12 * 60; | ||
| if (endTimeMinute.includes("p") && startTime > endTime) endTime += 12 * 60; |
There was a problem hiding this comment.
can we make these the same if and add a really short comment showing what sort of case we're trying to account for in both cases?
There was a problem hiding this comment.
Restructured the if statements and added a couple comments
Description
Modified the logic for calculating minutes since midnight for the start and end times of a provided time interval in
packages/stdlib/src/time-utils.ts. The previous logic caused the returned time to be shifted 12 hours earlier for times that ended in hour 12, resulting in values that were 720 minutes too early (sometimes even into the negative). This issue is now fixed by more precisely comparing the start and end times and noting whether am or pm is specified.Related Issue
This closes issue #316
Motivation and Context
This fixes a logic issue in parsing times that is relevant to the websoc and larc scrapers, removing errant responses.
How Has This Been Tested?
I tested this logic locally by testing it with a combination of input strings that worked prior and ones that gave errant results to confirm that it fixed the error without creating new ones.
Types of changes
Checklist: